home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1985 June / 1985-06.d64 / sid editor (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  11KB  |  403 lines

  1. 100 goto1000:rem                         ***** 16-bit calculation *****
  2. 200 kk=peek(key):ifkk=nullthen200
  3. 205 rem key pressed, use vars for speed
  4. 210 j=bb:z=peek(h+bb):hh=peek(shft)
  5. 215 rem cur-up=7,cur-lft=2,return=1
  6. 220 onkkgoto240,250,230,230,230,230,260
  7. 230 return:rem no valid key, keep value
  8. 240 j=int((z+bb)*k/cc):goto260
  9. 245 rem vry fast,larger for higher vals
  10. 250 j=k:rem moderate increment
  11. 260 z=peek(h)+z*xx+j*((hh=aa)-(hh>aa))
  12. 265 rem h set by caller, add incr
  13. 266 rem incr is pos if shift key down
  14. 270 ifz<aathenz=aa:rem min & max vals
  15. 280 ifz>zzthenz=zz
  16. 290 gosub930:rem position cursor
  17. 295 rem print value if pitch or filter
  18. 300 ifdv<>ccthenprintz"[157] ":goto320
  19. 305 rem print % of duty cycle
  20. 310 printint(z/4.095)/10"[157]%  "
  21. 315 rem put value in buffer
  22. 320 pokeh+bb,z/xx:pokeh,z-int(z/xx)*xx
  23. 330 ifdv>ccthen360:rem branch for fltr
  24. 335 rem put val in sid, back for more
  25. 340 pokeyy,peek(h):pokeyy+bb,peek(h+bb)
  26. 350 goto200
  27. 355 rem filter is odd; 11-bit value
  28. 356 rem stored 3 low, 8 high
  29. 360 pokeyy,zand7:pokeyy+bb,z/8
  30. 370 goto200:rem                          ***** 8-bit calculation *****
  31. 400 kk=peek(key):ifkk=nullthen400
  32. 405 rem key pressed, is it valid?
  33. 410 onkkgoto430,430,420,420,420,420,430
  34. 415 rem no, return with value kept
  35. 420 return
  36. 430 hh=peek(shft):bb=sbuf+h
  37. 435 rem add increment (same for any
  38. 436 rem valid key), pos if shift down
  39. 440 z=(peek(bb)andj)/k+(hh=0)-(hh>0)
  40. 450 ifz<0thenz=0:rem min & max values
  41. 460 ifz>15thenz=15
  42. 470 gosub930:printz"[157]  ":rem pos & prnt
  43. 475 rem mask on to byte
  44. 480 z=peek(bb)and255-jorz*k
  45. 485 rem insert & go back for more
  46. 490 pokebb,z:pokesid+h,z:goto400:rem     ***** bit decoding *****
  47. 700 yy=peek(sbuf+xx):rem value of byte
  48. 710 z=int((yyandj)/k):rem val of bit(s)
  49. 715 rem mask values set by caller
  50. 720 return:rem                           ***** bit encoding *****
  51. 800 yy=yyand255-jorz*k:rem encode
  52. 810 pokesbuf+xx,yy:rem set buffer
  53. 820 pokesid+xx,yy:rem set sid
  54. 830 return:rem                           ***** cursor plotter *****
  55. 900 pokecx,wx%(ct)+cl:rem word row
  56. 910 pokecy,wy%(ct)+ofs:rem & column
  57. 920 goto950
  58. 930 pokecx,vx%(ct)+cl:rem value row
  59. 940 pokecy,vy%(ct):rem     & column
  60. 950 sysmove:return:rem move cursor
  61. 996 rem                                  ** main routine **
  62. 1000 gosub 50000:rem initialize          ***** key input *****
  63. 1100 kk=peek(key):ifkk=nullthen1100
  64. 1105 rem key pressed, if shift is
  65. 1106 rem down, skip entry level calc
  66. 1110 hh=peek(shft):ifhh=1then1500
  67. 1115 rem entry level into voices?
  68. 1120 ifkk<f1orkk>f5then1500
  69. 1125 rem change entry level & clear
  70. 1130 el=kk-4:dv=-1:gosub53000:goto1100
  71. 1496 rem                                 ***** key dispatch *****
  72. 1500 ifkk=fthen2000:rem frequency
  73. 1510 ifkk=pthen2000:rem pulse width
  74. 1520 ifkk=athen3000:rem attack
  75. 1530 ifkk=dthen3000:rem decay
  76. 1540 ifkk=sthen3000:rem sustain
  77. 1550 ifkk=rthen3000:rem release
  78. 1560 ifkk=wthen4000:rem waveform
  79. 1570 ifkk=gthen4000:rem gate
  80. 1580 ifkk=ithen4000:rem ring
  81. 1590 ifkk=ythen4000:rem sync
  82. 1600 ifkk=qthen2000:rem filter freq
  83. 1610 ifkk=nthen3000:rem resonance
  84. 1620 ifkk=vthen3000:rem volume
  85. 1630 ifkk=mthen5000:rem mode
  86. 1640 ifkk=n1then5000:rem assign
  87. 1650 ifkk=n2then5000
  88. 1660 ifkk=n3then5000
  89. 1670 ifkk=xthen5000
  90. 1680 ifkk=othen6000:rem osc3
  91. 1690 ifkk=ethen6000:rem env3
  92. 1700 ifkk=tthen5000:rem 3 off
  93. 1705 rem special functions
  94. 1710 ifkk=f1thengosub7000:goto1100
  95. 1720 ifkk=f3thengosub7000:goto1100
  96. 1730 ifkk=f5thengosub7000:goto1100
  97. 1740 ifkk<>f7orhh=0then1800:rem end?
  98. 1750 geta$:ifa$<>""then1750:rem clr buf
  99. 1760 pokesid+24,0:syscs:end:rem end
  100. 1800 dv=-1:gosub53020:rem no valid key
  101. 1810 gosub52000:goto1100:rem oops        ***** 16-bit evaluation *****
  102. 2000 dv=1:ifkk=pthendv=2
  103. 2010 ifkk=qthendv=12
  104. 2015 rem dv:1=voice freq, 2=pls wdth
  105. 2016 rem 12=filter freq, clear old
  106. 2017 rem vars used for speed
  107. 2018 rem zz=max val, h=sid reg
  108. 2020 gosub53020:xx=256:aa=0:bb=1:cc=2
  109. 2030 k=29:h=0:zz=65535:j=7
  110. 2040 ifdv=2thenzz=4095:h=2
  111. 2050 ifdv=12thenzz=2047:h=21:j=0
  112. 2055 rem pre-calculate buffer & sid
  113. 2056 rem entry points
  114. 2060 yy=sid+el*j+h:h=sbuf+el*j+h
  115. 2065 rem calc & display values
  116. 2066 rem once a non-valid key is found
  117. 2067 rem in subroutine, exit with key
  118. 2068 rem value intact
  119. 2070 gosub200:goto1110:rem               ***** 8-bit evaluation *****
  120. 3000 dv=4:h=el*7+5:j=240:k=16:rem atck
  121. 3005 rem decay, sustain, release?
  122. 3010 ifkk=dthendv=5:j=15:k=1
  123. 3020 ifkk=sthendv=6:h=el*7+6
  124. 3030 ifkk=rthendv=7:h=el*7+6:j=15:k=1
  125. 3035 rem resonance or volume?
  126. 3040 ifkk=nthendv=13:h=23
  127. 3050 ifkk=vthendv=14:h=24:j=15:k=1
  128. 3055 rem clear, calc & display values
  129. 3056 rem when non-valid key pressed,
  130. 3057 rem return with value intact
  131. 3060 gosub53020:gosub400:goto1110:rem    ***** ctrl byte calculation *****
  132. 4000 dv=-1:gosub53020:rem clear
  133. 4005 rem set mask values
  134. 4010 xx=4+el*7:dv=3:j=240:rem waveform
  135. 4020 ifkk=gthendv=8:j=1:rem gate
  136. 4030 ifkk=ithendv=9:j=4:rem ring
  137. 4040 ifkk=ythendv=10:j=2:rem sync
  138. 4050 k=j:ifj=240thenk=16
  139. 4055 rem go get value from sid buffer
  140. 4056 rem branch if waveform
  141. 4060 gosub700:ifdv=3then4110
  142. 4066 rem toggle value
  143. 4070 z=-(z=0):cl=el*5:ct=dv
  144. 4080 ifz=1thenprint"";:rem highlight
  145. 4090 gosub53070:goto4190:rem display
  146. 4100 rem
  147. 4105 rem inc 0->1,1->2,2->4,4->8,8->0
  148. 4110 z=(z*2-(z=0))*-(z<8)
  149. 4120 ct=dv:cl=el*5:gosub930:rem mve crs
  150. 4125 rem display waveform
  151. 4130 a$="-":ifz=1thena$="t
  152. 4140 [139]z[178]2[167]a$[178]"s
  153. 4150 ifz=4thena$="p
  154. 4160 [139]z[178]8[167]a$[178]"n
  155. 4170 printa$
  156. 4180 rem
  157. 4190 gosub800:goto1100:rem store & rtrn  ***** filt/mode calculation *****
  158. 5000 dv=-1:gosub53020:rem clear old
  159. 5010 dv=15:ct=dv:cl=0:rem mode
  160. 5015 rem filter assignment?
  161. 5020 ifkk=n1thendv=16:h=1:goto5500
  162. 5030 ifkk=n2thendv=17:h=2:goto5500
  163. 5040 ifkk=n3thendv=18:h=4:goto5500
  164. 5050 ifkk=xthendv=19:h=8:goto5500
  165. 5055 rem 3 off?
  166. 5060 ifkk=tthendv=22:goto5200
  167. 5070 rem
  168. 5075 rem mode increment
  169. 5080 xx=24:j=112:k=16:gosub700
  170. 5085 rem incr 0->1,1->2,2->4,4->0
  171. 5086 rem program modification possible
  172. 5087 rem to allow more than one mode
  173. 5088 rem at the same time
  174. 5090 z=(z*2-(z=0))*-(z<4)
  175. 5100 gosub930:rem move cursor
  176. 5110 a$=" -":ifz=1thena$="lp
  177. 5120 [139]z[178]2[167]a$[178]"bp
  178. 5130 ifz=4thena$="hp
  179. 5140 [153]a$:[137]5550:[143] display
  180. 5150 [143]
  181. 5155 [143] turn 3 off
  182. 5200 ct[178]dv:xx[178]24:j[178]128:k[178]1:[141]700
  183. 5205 [143] mask & toggle
  184. 5210 zz[178]128[172][171]((z[175]j)[178]0):h[178]1:[137]5520
  185. 5220 [143]
  186. 5225 [143] assign filter
  187. 5500 ct[178]dv:xx[178]23:j[178]15:k[178]1:[141]700
  188. 5510 zz[178]h[172][171]((z[175]h)[178]0):[143] mask & toggle
  189. 5520 [139]zz[177]0[167][153]"";
  190. 5530 [141]53090:[143] display
  191. 5540 z[178]z[175]j[171]h[176]zz
  192. 5550 [141]800:[137]1100:[143] store & rtrn  ***** i/o insert *****
  193. 6000 dv[178][171]1:[141]53020:[143] clear
  194. 6005 [143] default to osc
  195. 6010 h[178]os:ct[178]20:cl[178]0:[139]kk[178]o[167]6030
  196. 6015 [143] envelope
  197. 6020 h[178]en:ct[178]21
  198. 6030 j[178][194](h):[143] read value
  199. 6035 [143] value switch
  200. 6036 [143] either 255 (off),0 (voice 1,
  201. 6037 [143] low),1 (voice 1, high), or 22
  202. 6038 [143] (filter frequency, high)
  203. 6040 j[178][171](j[178]0)[171]22[172](j[178]1)[171]255[172](j[178]22)
  204. 6050 [151]h,j:[141]930:[143] save & move
  205. 6055 [143] calculate display
  206. 6060 j[178]1[171](j[177]0)[171](j[177]1)[171](j[177]22)
  207. 6070 [153][202]("lhf-",j,1):[137]1100
  208. 6996 [143]                                 ***** function keys *****
  209. 7000 dv[178][171]1:[141]53020:[143] clear
  210. 7005 [143] cannot arrive here unless
  211. 7006 [143] shift key was pressed, so
  212. 7007 [143] f1=f2,f3=f4,f5=f6
  213. 7010 h[178]0:ct[178]8:j[178]1:k[178]1:[143] default
  214. 7015 [143] f1(f2)=toggle, f3(f4)=all off
  215. 7020 [139]kk[178]f1[176]kk[178]f3[167]7100
  216. 7025 [143] f5(f6)=on then off
  217. 7026 [143] z=read value, set to 1
  218. 7027 [143] will cause a toggle to 0
  219. 7028 [143] h serves to adjust z
  220. 7030 h[178]1:[141]7100
  221. 7040 h[178]2
  222. 7095 [143] voice gates at sid+4,11,18
  223. 7100 [129]xx[178]4[164]18[169]7
  224. 7105 :[143] if f3, set to turn off
  225. 7110 :[141]700:[139]kk[178]f3[167]z[178]1
  226. 7115 :[143] adjust for f5
  227. 7120 :[139]h[177]0[167]z[178]h[171]1
  228. 7125 :[143] calculate display row
  229. 7130 :cl[178][171]5[172](xx[178]11)[171]10[172](xx[178]18)
  230. 7135 :[143] display as on/off
  231. 7140 :[145](z[179][177]1)[170]2[141]53060,53070
  232. 7150 :z[178][171](z[178]0):yy[178]yy[175]254[176]z
  233. 7155 :[143] save in buffer
  234. 7160 :[151]sbuf[170]xx,yy
  235. 7170 [130